class FinishedIn {
  String? id;
  String? workOrderId;
  String? workshopId;
  String? locationId;
  String? productorderno;
  String? productName;
  String? productCode;
  String? productstyle;
  String? batchno;
  String? stockqty;
  String? unitname;
  String? warehouseId;

  FinishedIn({
    this.id,
    this.workOrderId,
    this.workshopId,
    this.locationId,
    this.productorderno,
    this.productName,
    this.productCode,
    this.productstyle,
    this.batchno,
    this.stockqty,
    this.unitname,
    this.warehouseId,
  });

  FinishedIn copyWith({
    String? id,
  }) {
    return new FinishedIn(
      id: id ?? this.id,
    );
  }

  @override
  String toString() {
    return '''FinishedIn{
      id: id,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is FinishedIn &&
          runtimeType == other.runtimeType &&
          id == other.id);

  factory FinishedIn.fromMap(Map<String, dynamic> map) {
    return new FinishedIn(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      productorderno: map['productorderno'] != false
          ? map['productorderno'].toString() as String?
          : "",
      productCode: map['product_tmpl_id']['default_code'] != false
          ? map['product_tmpl_id']['default_code'].toString() as String?
          : "",
      productName: map['product_tmpl_id']['name'] != false
          ? map['product_tmpl_id']['name'].toString() as String?
          : "",
      productstyle: map['product_tmpl_id']['description'] != false
          ? map['product_tmpl_id']['description'].toString() as String?
          : "",
      batchno:
          map['batchno'] != false ? map['batchno'].toString() as String? : "",
      stockqty:
          map['quantity'] != false ? map['quantity'].toString() as String? : "",
      unitname: map['product_uom_id'][1] != false
          ? map['product_uom_id'][1].toString() as String?
          : "",
      warehouseId: map['location_id'][1] != false
          ? map['location_id'][1].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.productorderno != null && this.productorderno != '')
        ['plancode', 'like', '%${this.productorderno}%'],
      if (this.productName != null && this.productName != '')
        ['name', 'like', '%${this.productName}%'],
      if (this.locationId != null && this.locationId != '')
        ['location_id', '=', int.parse(this.locationId!)],
      if (this.workshopId != null && this.workshopId != '')
        ['workshop_id', '=', int.parse(this.workshopId!)],
    ] as List;
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
    } as Map<String, dynamic>;
  }
}
